package com.taotao.cart.threadlocal;

import com.taotao.cart.pojo.User;

/**
 * 编写threadlocal线程变量
 * @author joedy
 *
 */
public class UserThreadLocal {

	public static final ThreadLocal<User> THREADLOCAL = new ThreadLocal<>();
	
	/**
	 * 给线程变量设置参数
	 * @param user
	 */
	public static void set(User user){
		THREADLOCAL.set(user);
	}
	
	/**
	 * 获取线程变量
	 * @return
	 */
	public static User get(){
		return THREADLOCAL.get();
	}
	
	/**
	 * 释放资源
	 */
	public static void remove(){
		THREADLOCAL.remove();
	}
}
